package org.example.domain;

import com.baomidou.mybatisplus.annotation.FieldFill;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Data;
import org.springframework.format.annotation.DateTimeFormat;

import javax.validation.constraints.NotNull;
import javax.validation.constraints.Null;
import java.util.Date;
import java.util.List;

@Data
@TableName("question")
public class Question {

    public interface Save{};
    public interface Update{};

    @TableId("id")
    @NotNull(message = "问题ID不能为空",groups = {Update.class})
    @Null(message = "问题ID必须为空",groups = {Save.class})
    private Integer questionId;

    @NotNull(message = "题目不能为空",groups = {Save.class})
    private String title;

    @NotNull(message = "题目难度不能为空",groups = {Save.class})
    private String level;

    private float rate;

    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone="GMT+8")
    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @TableField(value = "create_time",fill = FieldFill.INSERT)
    private Date createTime;
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone="GMT+8")
    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @TableField(value = "update_time",fill = FieldFill.UPDATE)
    private Date updateTime;

    @TableField(exist = false)
    private List<String> type;

    @TableField(exist = false)
    private QuestionContent questionContent;

}
